package com.woniu.springbootshiro.controller;


import com.woniu.springbootshiro.pojo.Set;
import com.woniu.springbootshiro.service.SetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class SetController {

    @Autowired
    private SetService setService;
    @RequestMapping("/queryAllLamp")
    @ResponseBody
    public List<Set> queryAllLamp(){
        System.out.println("进入了 List<Set> queryAllLamp()方法");
    List<Set> set =setService.queryAllLamp();
            return set;
    }

    @RequestMapping("/queryBad")
    @ResponseBody
    public List<Set> queryBad(){
        System.out.println("进入了查询损坏设备的方法");
        List<Set> sets =setService.queryBad();
        return sets;
    }

    @RequestMapping("/delLamp")
    public void delLamp(Integer id, HttpServletResponse resp) throws IOException {
           if(setService.delLamp(id)==1){
               resp.getWriter().write("1");
           }else{
               resp.getWriter().write("0");
           }
    }




}
